package StudyCode.summary.mycollection;

import java.util.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CreateACollectionContainingTheGivenSizeOfTheGivenStrings {
	public static void main(String[] argv) throws Exception {
		int size = 2;
		String strings = "www.tah1986.com";
		System.out.println(newRandomStringList(size, strings));
	}

	private static final Random RANDOM = new Random();


	private static Collection<String> newRandomStringList(int size, String... strings) {

		List<String> list = new ArrayList<>(size);

		for (String string : strings) {
			for (int i = 0; i < size / 3; i++) {
				list.add(string);
			}
		}

		if (list.size() < size) {
			for (int i = list.size(); i < size; i++) {
				list.add(strings[i % strings.length]);
			}
		}

		Collections.shuffle(list, RANDOM);

		return list;
	}
}
